	//======================================>>>manager proto type
	var MNG = {
		fncRtnfunc : function(mode, flag, code_seq) {
			if ( mode == "reg" ) {
				if ( flag.lastIndexOf('item_no1')>=0 ||flag.lastIndexOf('other_no1')>=0 ) {
					var code_code1 = code_seq;
					MNG.fncReg("/mng/"+flag+"_reg.html?cd1="+code_code1, flag);
				}
				else
					MNG.fncReg("/mng/"+flag+"_reg.html", flag);
			}
			if ( mode == "mod" )
				MNG.fncMod("/mng/"+flag+"_mod.html", flag);
			if ( mode == "del" )
				MNG.fncDel(flag, "d", "json", "/mng/mng_do.html");
			if ( mode == "rst" )
				MNG.fncRst("/mng/"+flag+".html", flag);
			if ( mode == "list" )
				MNG.fncList("/mng/"+flag+".html", code_seq);
			if ( mode == "sort" ) {
				var disp_cal = flag;
				MNG.fncSort("s", flag, code_seq);
			}
			if ( mode == "print" )
				MNG.fncPrint(flag);
			if ( mode == "excel" )
				MNG.fncExcel(flag);
		},
		fncExcel : function(flag) {

			Obj = MNG.fncGetPrintExcelObj(flag);
		    var header = MNG.fncRtnHeader();
		    var body	= MNG.fncRtnBody(Obj);
			var xlsList = header+body;
	
			$('#excelList').val(xlsList);
			
			if ( flag == 'member' || flag == 'farm' )
				$('#excel_flag').val(flag);
			if ( flag == 'farm' )
				$('#excel_schVal').val( $('#schVal').val() );
			
			$('#xlsFrm').submit(); 	
			
			$('#excel_flag').val('');
			$('#excel_schVal').val('');
			$('#excelList').val('');
		},
		fncPrint : function(flag) {
			Obj = MNG.fncGetPrintExcelObj(flag);

			var W = 720;         
		    var H = 600;
		    //var features = "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=" + W + ",height=" + H + ",left=0,top=0";
		    var features = "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,left=0,top=0";
		    var PrintPage = window.open("about:blank",Obj.id,features); 
		    PrintPage.document.open(); 

		    var header = MNG.fncRtnHeader();
		    var body	= MNG.fncRtnBody(Obj);

		    PrintPage.document.write(header+body);
		    PrintPage.document.close(); 
		    //PrintPage.document.title = document.domain;
		    PrintPage.print(PrintPage.location.reload());

		},
		fncGetPrintExcelObj : function(flag) {
		    /* Chrome possible
		    var print_contents = $("#div_erpTable").html();
		    $("#print_iframe").contents().find("body").html(print_contents);
		    $("#print_iframe").contents().find("input:checkbox").hide();
		    $("#print_iframe").focus();
		    frames["print_iframe"].focus();
		    frames["print_iframe"].print();
		     */
			Obj = $("#div_erpTable");
			Obj.html('');
			Obj.append($("table:.erpTable").clone());

			//tr 오브젝트를 찾아서 input이 있으면 해당 elemnet를 삭제한다.
			TrObj = Obj.contents().find("tr");
			
			var idx = 0;
			var now_disps = $("input[name=now_disp]");
			
			TrObj.each(function() {
				if ( $(this).find("th").find("input") ){
					//농가일때는 표구성의 특성으로 숨김모드로 한다.
					if (flag=='farm')
					{
						$(this).find("th").find("input").hide();
					}
					else{
						$(this).find("th:eq(0)").remove();
					}
				}
				if ( $(this).find("td").find("input") ){
					if (flag=='farm')
					{
						$(this).find("td").find("input").hide();
					}
					else{
						$(this).find("td:eq(0)").remove();
					}
				}
		
				//서브코드리스트에서 순서조정 그림 지우기
				if (flag=='code2') {
					if ( $(this).find("td").find("span") ){
						//타이틀 tr이 있으므로  -1 add
						$(this).find("td").eq(2).html( now_disps.eq(idx-1).val() );
					}
				}
				
				idx++;
			});
			return Obj;
		},
		fncRtnBody : function(obj) {
			ListTitleObj = $(".tableTitle");
		    var body	= "<body>";
		    body	   += '<p class="tableTitle">'+ListTitleObj.html()+'</p>';
		    body	   += obj.html();
		    body	   += "</body></html>";
		    return body;
		},
		fncRtnHeader : function() {
		    var  header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
		    header 	   += '<html xmlns="http://www.w3.org/1999/xhtml">';
		    header 	   += '<head>';
		    header 	   += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
		    header 	   += '<title>:: 농협전북지부 ERP시스템 ::</title>';
		    header 	   += '<link href="/css/layout.css" type="text/css" rel="stylesheet" />';
		    header 	   += '<style>';
		    header 	   += 'table { border-color: #000000; border-style: solid; }'; 
		    header 	   += 'td { border-color: #000000; border-style: solid; }';
		    header 	   += '</style>';
		    header 	   += '</head>';
		    return header;
		},
		fncList : function(url, code_seq) {
			$(location).attr('href', url+"?cds="+code_seq );
		},
		fncReg : function(url, flag) {
			if ( flag == 'NH' ||flag.lastIndexOf('item')>=0 ||flag.lastIndexOf('other')>=0||flag.lastIndexOf('destination')>=0 ){
				var height=200;
				if ( flag.lastIndexOf('item')>=0 ||flag.lastIndexOf('other')>=0||flag.lastIndexOf('destination')>=0 ) 
					height = 170;
				window.open(url,'','width=400,height='+height+',scrollbars=no');
			}
			else
				$(location).attr('href', url);
		},
		fncMod : function(url, flag) {
			var action_url = url;
			f = document.forms.frm;
			f.action=action_url;

			var chkCnt = $("input[name=chkbxNo]:checked").size();

			if ( chkCnt != 1 ) {
				alert("수정할 레코드 한개를 선택해 주세요");
			}
			else {
				if ( flag == 'NH' ||flag.lastIndexOf('item')>=0 ||flag.lastIndexOf('other')>=0||flag.lastIndexOf('destination')>=0 ){
					var height=200;
					if ( flag.lastIndexOf('item')>=0 ||flag.lastIndexOf('other')>=0||flag.lastIndexOf('destination')>=0 )
						height = 170;
					var win = window.open('about:blank','nhpopup','width=400,height='+height+',scrollbars=no');
					f.target = "nhpopup";
					if ( win != null ){
						f.target = "nhpopup";
						f.submit();
					}
				}
				else
					f.submit();
			}
		},
		fncRst : function(url, flag) {
			f = document.forms.frm;
			f.reset();
			if ( flag == 'NH' ||flag.lastIndexOf('item')>=0 ||flag.lastIndexOf('other')>=0||flag.lastIndexOf('destination')>=0 ){
				window.close();
			}
			else
				location.replace(url);
		},		
		fncDel : function(flag, mode, dataType, url) {
			var chkCnt = $("input[name=chkbxNo]:checked").size();
			if ( chkCnt == 0 ) {
				alert("삭제할 레코드를 선택해 주세요");
			}
			else {
				var isProccess = confirm (chkCnt+"개를 삭제하시겠습니까?");
				if ( isProccess ) {
					var handle_seq = $("input[name=chkbxNo]:checked").serializeArray();
					$.ajax({
						type: 'POST',
						url: url,
						data: {
							  flag:flag
							, handle_seq:handle_seq
							, mode:mode
						} ,
						dataType: 'json',
						traditional : false,
						success: function (response) {
							if (response.resultCode == '200')
							{
								alert(response.successCnt+'개의 레코드가 삭제되었습니다.');
								location.reload();
							}
							else
								alert('실패했습니다.');
						},
						error: function (request, textStatus, errorThrown) {
							alert('실패했습니다. 잠시 후에 다시 시도해 주세요.'+textStatus+","+errorThrown);
						}
					});
				}
			}
		},
		fncSort : function(mode, disp_cal, code_seq ) {
			var url = "/mng/mng_do.html";
			var disp_max = $("input[name=max_code_display]").val();
			var code_disp = $("span[name=up_span"+code_seq+"]").attr("code_disp");
			//alert(mode+","+disp_cal+","+code_seq+","+disp_max+","+code_disp);
			
			if ( disp_max == code_disp && disp_cal == 'plus' ) {
				alert('마지막입니다.');
			}
			else
			if ( code_disp == '1' && disp_cal == 'minus' ) {
				alert('처음입니다.');
			}
			else {
				//do something to check
				var isProccess = true;
				if ( isProccess ) {

					var code_seqs = $("input[name=chkbxNo]");
					var now_disps = $("input[name=now_disp]");
					var due_disps = $("input[name=due_disp]");					
					var due_code_seq = code_seq;
					
					//rearrange
					for ( z = 0; z < code_seqs.size() ; z ++ )
					{
						if ( code_seqs.eq(z).val() == due_code_seq ){
							if ( disp_cal == 'plus' ){
								due_disps.eq(z).val(   parseInt( now_disps.eq(z  ).val(),10 ) + 1 );
								due_disps.eq(z+1).val( parseInt( now_disps.eq(z+1).val(),10 ) - 1 );
							}
							if ( disp_cal == 'minus' ){
								due_disps.eq(z).val(   parseInt( now_disps.eq(z  ).val(),10 ) - 1 );
								due_disps.eq(z-1).val( parseInt( now_disps.eq(z-1).val(),10 ) + 1 );
							}							
						}
					}
					
					for ( z = 0; z < code_seqs.size() ; z ++ )
					{
						var due_val = due_disps.eq(z).val();
						due_disps.eq(z).val(  due_val +  "," + code_seqs.eq(z).val() );
					}
					
					//배열로 넘긴다. code_disp | code_seq
					var due_dispsArr = $("input[name=due_disp]").serializeArray();
					$.ajax({
						type: 'POST',
						url: url,
						data: {
							  due_dispsArr:due_dispsArr
							, mode:mode
						} ,
						dataType: 'html',
						traditional : false,
						success: function (response) {
							location.reload();
						},
						error: function (request, textStatus, errorThrown) {
							alert('실패했습니다. 잠시 후에 다시 시도해 주세요.'+textStatus+","+errorThrown);
						}
					});
				}
			}
		},
		fncDummy : function(param1, param1) {
		}
	};

	var MSGPOOL = {
		props : {
			isLocal :  (document.domain =="")
		}
	};
	//======================================>>>manager proto type

	
	

	var pathname = window.location.pathname;

	//======================================>>> ready for calendar1
	var needCAL = new Array();
	needCAL.push('/mng/farm_reg.html');
	needCAL.push('/mng/farm_mod.html');
	var isNeedCAL = false;
	for ( z=0;z<needCAL.length;z++)
		if ( pathname == needCAL[z] )
			isNeedCAL = true;
	if ( isNeedCAL ) {
		document.write('<link type="text/css" href="/css/hot-sneaks/jquery-ui-1.8.18.custom.css" rel="stylesheet" />');
	}
	//======================================>>> ready for calendar1
	
	
	
	//======================================>>> get jquery & validation plugin
	document.write('<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>');
	document.write('<script type="text/javascript" src="/js/jquery.validate-1.8.0.js"></script>');
	//======================================>>> get jquery & validation plugin
	
	
	
	
	//======================================>>> ready for calendar2
	if ( isNeedCAL ) {
		document.write('<script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>');
		document.write('<script type="text/javascript" src="/js/common.js"></script>');
	}
	//======================================>>> ready for calendar2	
	

	function fnCheckAll() {
		id="chkAll";
		$("INPUT[type='checkbox']").attr('checked', $('#' + id).is(':checked'));
	}
	
	function fncGetFarmItem2(type, level, code, area, checklist){
		if (code!="")
		{
			$.ajax({
				type: 'POST',
				url: '/order/ajax_code_responseJSON.html',
				data: {
					  type:type
					, level:level
					, code:code
				} ,
				dataType: 'json',
				traditional: true,
				success: function (response) {
					if (response.resultCode == '200') {
						fncFarmCheckBoxPrint(level, area, response, checklist);
					}
					else
					{
						alert('실패했습니다. 잠시 후에 다시 시도해 주세요');
					}
				},
				error: function (request, textStatus, errorThrown) {
					alert("실패했습니다. 잠시 후에 다시 시도해 주세요.");
				}
			});
		}
	}
	
	function fncFarmCheckBoxPrint(level, area, data, checklist)
	{
		var count = data.resultSet.length;
		var html = "";
		for ( i = 0 ; i < count ; i++ ) {
			var row = data.resultSet[i].row_array;
			if (level==1)
				var code=row.CODE_CODE1;
			else if (level==2)
				var code=row.CODE_CODE2;
			var codename=row.CODE_NAME;
			
			html += '<input type="checkbox" name="farm_itemcode2[]" id="farm_itemcode2[]" onClick="fncFarmItemSync(this);" value="'+code+'"';
			//checklist : 1,2,3,4
			if (checklist!=null){
				var checklist_arr = checklist.split(',');
				for ( z = 0 ; z < checklist_arr.length ; z++ ){
					if ( checklist_arr[z] == code )
						html += " checked ";
				}
			}
			html += "/> ";
			html += codename;
			html += "  ";
		}
		area.html(html);
	}
	
	function fncNHCodeCheck(checklist)
	{
		$("input:checkbox").each(function() {
			if (checklist!=null){
				var checklist_arr = checklist.split(',');
				for ( z = 0 ; z < checklist_arr.length ; z++ ){
					if ( checklist_arr[z] == $(this).val() )
						$(this).attr('checked', true);
				}
			}
		});
	}
	
	function fncFarmItemSync(obj){
		//somethind to do	
	}